<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'user-form',
	'enableAjaxValidation'=>false,
)); ?>


	<?php echo $form->errorSummary($model); ?>

    <div class="row">
        <?php echo $form->labelEx($model,'user_name'); ?>
        <?php echo $form->textField($model,'user_name',array('size'=>60,'maxlength'=>255)); ?>
        <?php echo $form->error($model,'user_name'); ?>
    </div>

	<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'name'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'password'); ?>
		<?php echo $form->passwordField($model,'password',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'password'); ?>
	</div>
    
    <div class="row">
        <?php echo $form->labelEx($model,'retype_password'); ?>
        <?php # echo $form->passwordField($model,'password',array('size'=>60,'maxlength'=>255)); ?>
        <input type="password" size="60" maxlength="255" id="retype_password" name="User[retype_password]">
        <?php # echo $form->error($model,'password'); ?>
    </div>

	<div class="row">
		<?php echo $form->labelEx($model,'email'); ?>
		<?php echo $form->textField($model,'email',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'email'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'phone'); ?>
		<?php echo $form->textField($model,'phone',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'phone'); ?>
	</div>

	<div class="row" style="display: none;">
		<?php echo $form->labelEx($model,'status'); ?>
		<?php echo $form->textField($model,'status'); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'roles'); ?>
        
        <div style="margin-left: 150px;">
            <span>
                <input type="checkbox" name="roles['MEMBER']" value="MEMBER" id="MEMBER">
                <label for="MEMBER">MEMBER</label>
            </span>
            <br>
            
            <span>
                <input type="checkbox" name="roles['MODERATOR']" value="MODERATOR" id="MODERATOR">
                <label for="MODERATOR">MODERATOR</label>
            </span>
            <br>
            
            <span>
                <input type="checkbox" name="roles['ADMIN']" value="ADMIN" id="ADMIN">
                <label for="ADMIN">ADMIN</label>
            </span>
            <br>
            
            <span>
                <input type="checkbox" name="roles['SUPER_ADMIN']" value="SUPER_ADMIN" id="SUPER_ADMIN">
                <label for="SUPER_ADMIN">SUPER_ADMIN</label>
            </span>
        </div>
        
        
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->


<script>
    $("form#user-form").submit(function() {
        var password=$("#User_password").val();
        var retype_password=$("#retype_password").val();
        
        var user_name=$("#User_user_name").val();
        var name=$("#retype_password").val();
        
        if(password!==retype_password){
            alert(" Mật khẩu không khớp, vui lòng nhập lại");
            return false;
        }
        
        if(user_name=='' || name=='' || password=='' || retype_password=='') return false;
        
        
    });
</script>